#include "pch.h"

Enemy::Enemy()
{
    xPos = 0;
    yPos = 0;
    bounceAmount = 0;
}

void Enemy::spawn(float y)
{
    xPos = GraphicsDevice::sInstance->getScreenWidth() + 50;
    yPos = y;

}

void Enemy::destroy()
{
    clear_surface();
}

void Enemy::show_object()
{
    GraphicsDevice::sInstance->apply_surface(x, y, 0, 0, image, GraphicsDevice::sInstance->getGameScreen());
}

void Enemy::move_object(Projectile* projectile)
{
    x -= xVel * (FPSCounter::sInstance->update.getTicks() / 1000.f);
    y += yVel * (FPSCounter::sInstance->update.getTicks() / 1000.f);
    xVel = projectile->getXVel(); //+ (FPSCounter::sInstance->update.getTicks() / 1000.f);
    yVel = projectile->getYVel(); //+ (FPSCounter::sInstance->update.getTicks() / 1000.f);
}

void Enemy::clear_surface()
{
    SDL_FreeSurface(image);
}

void Enemy::setImage(std::string imgName)
{
    image = GraphicsDevice::sInstance->load_image(imgName);
}
